  // 获取每个class元素
  let inputObj = document.querySelector('.search .tet');
  let ulObj = document.querySelector('.search .search-res')
  // 给输入框添加表单事件，制行函数
  inputObj.addEventListener('input', inputMsg);
  // 设置变量，为空字符串
  let times = '';

  function inputMsg() {

    clearTimeout(times);    
    times = setTimeout(function () {

      let content = inputObj.value;

      createEle(content);
    }, 500);
  }
 //  搜索框，请求的是百度的数据
  function createEle(val) {
    let script = document.createElement('script');
    script.src = "https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd=" + val + "&json=1&p=3&sid=22084_1436_13548_21120_22036_22073&req=2&csor=0&cb=callback";;
    document.head.appendChild(script);
  }

  function callback(msg) {

    let kw = msg.s;

    let str = '';
    kw.forEach(ele => {
      str += '<li>' + ele + '</li>';
    });

    ulObj.innerHTML = str;
  }
  ulObj.onclick = function(){
    ulObj.style.display = "none";
  }



 /* 
  class sou{
      constructor(){
          this.inputObj = document.querySelector('.search .tet');
          this.ulObj = document.querySelector('.search .search-res')
      }
      addEvent(){
          this.times=''
          var that =this;
          this.inputObj.oninput=function(){
              console.log(1)
            clearTimeout(times);    
            that.times = setTimeout(function () {
        
              that.content = that.inputObj.value;
        
              that.createEle(content);
            }, 500);
          }
      }
      createEle(val){
        this.script = document.createElement('script');
        this.script.src = "https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd=" + val + "&json=1&p=3&sid=22084_1436_13548_21120_22036_22073&req=2&csor=0&cb=callback";;
        document.head.appendChild(this.script);
      }
      callback(msg){
        this.kw = this.msg.s;

        this.str = '';
        this.kw.forEach(ele => {
          this.str += '<li>' + ele + '</li>';
        });
    
        this.ulObj.innerHTML = this.str;
      }
  }
  var t=new sou;
  t.addEvent();
  t.callback() */